#include "diskeditor.h"
#include "ui_diskeditor.h"
#include <QMessageBox>

DisKEditor::DisKEditor(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DisKEditor)
{
    ui->setupUi(this);
}

const QString DisKEditor::name()
{
    return ui->nameEditor->text();
}

const QString DisKEditor::point()
{
    return ui->pointEditor->text();
}

const QString DisKEditor::type()
{
    return ui->typeEditor->text();
}

void DisKEditor::setName(const QString &value)
{
     ui->nameEditor->setText(value);
}

void DisKEditor::setPoint(const QString &value)
{
     ui->pointEditor->setText(value);
}

void DisKEditor::setType(const QString &value)
{
     ui->typeEditor->setText(value);
}

void DisKEditor::clear()
{
    ui->nameEditor->setText("");
    ui->pointEditor->setText("");
    ui->typeEditor->setText("");
}

DisKEditor::~DisKEditor()
{
    delete ui;
}

void DisKEditor::valid()
{
    if (ui->nameEditor->text() == "") {
        QMessageBox::critical(this,tr("Error"),tr("The name can't be empty."));
        return ;
    }
    if (ui->pointEditor->text() == "") {
        QMessageBox::critical(this,tr("Error"),tr("The mount point can't be empty."));
        return ;
    }
    accept();
}
